package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.YhLogDisplayConversion;
import com.ruoyi.system.service.IYhLogDisplayConversionService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 日志显示转化Controller
 * 
 * @author dr
 * @date 2023-07-19
 */
@RestController
@RequestMapping("/conversion")
public class YhLogDisplayConversionController extends BaseController
{
    @Autowired
    private IYhLogDisplayConversionService yhLogDisplayConversionService;

    /**
     * 查询日志显示转化列表
     */
    @RequiresPermissions("system:conversion:list")
    @GetMapping("/list")
    public TableDataInfo list(YhLogDisplayConversion yhLogDisplayConversion)
    {
        startPage();
        List<YhLogDisplayConversion> list = yhLogDisplayConversionService.selectYhLogDisplayConversionList(yhLogDisplayConversion);
        return getDataTable(list);
    }

    /**
     * 导出日志显示转化列表
     */
    @RequiresPermissions("system:conversion:export")
    @Log(title = "日志显示转化", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YhLogDisplayConversion yhLogDisplayConversion)
    {
        List<YhLogDisplayConversion> list = yhLogDisplayConversionService.selectYhLogDisplayConversionList(yhLogDisplayConversion);
        ExcelUtil<YhLogDisplayConversion> util = new ExcelUtil<YhLogDisplayConversion>(YhLogDisplayConversion.class);
        util.exportExcel(response, list, "日志显示转化数据");
    }

    /**
     * 获取日志显示转化详细信息
     */
    @RequiresPermissions("system:conversion:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yhLogDisplayConversionService.selectYhLogDisplayConversionById(id));
    }

    /**
     * 新增日志显示转化
     */
    @RequiresPermissions("system:conversion:add")
    @Log(title = "日志显示转化", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YhLogDisplayConversion yhLogDisplayConversion)
    {
        return toAjax(yhLogDisplayConversionService.insertYhLogDisplayConversion(yhLogDisplayConversion));
    }

    /**
     * 修改日志显示转化
     */
    @RequiresPermissions("system:conversion:edit")
    @Log(title = "日志显示转化", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YhLogDisplayConversion yhLogDisplayConversion)
    {
        return toAjax(yhLogDisplayConversionService.updateYhLogDisplayConversion(yhLogDisplayConversion));
    }

    /**
     * 删除日志显示转化
     */
    @RequiresPermissions("system:conversion:remove")
    @Log(title = "日志显示转化", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yhLogDisplayConversionService.deleteYhLogDisplayConversionByIds(ids));
    }
}
